<template>
  <div class="filesBox">
    <div class="files-top">
      <div
        v-if="processList.length == 0"
        style="
          width: 100%;
          line-height: 500px;
          font-size: 30px;
          text-align: center;
          color: #ccccccb0;
        "
      >
        暂无数据
      </div>
      <img v-else :src="currentImg" alt="" />
    </div>
    <div class="files-bottom">
      <div class="titleBox">
        <span>工艺图</span>
      </div>
      <div class="processBox">
        <div
          v-if="processList.length == 0"
          style="width: 100%; font-size: 30px; text-align: center; color: #ccccccb0"
        >
          暂无数据
        </div>
        <div
          v-for="(item, index) in processList"
          v-else
          :key="index"
          class="processList"
          :class="{ activeImg: currentImgId == index }"
          @click="handleClickImg(item, index)"
        >
          <img :src="item.pmtdz" alt="" />
          <div>{{ item.pmtmc }}</div>
        </div>
      </div>
    </div>
  </div>
</template>
<script setup lang="ts">
import { queryPmtxxb } from '@/service'
import { useBusinessStore } from '@/store'
const store = useBusinessStore()
// 平面图list
const processList: any = ref([])
// 点击ID
const currentImgId = ref(0)
// 点击展示平面图
const currentImg = ref('')
const getList = (id: string) => {
  queryPmtxxb({ qyId: id }).then((res: any) => {
    if (res.length == 0 || res == null) {
      currentImg.value = ''
    } else {
      processList.value = res
      currentImg.value = res[0].pmtdz
    }
  })
}
// 监听警情ID
const qyid = computed(() => {
  return store.jqInfo.zddwid
})
watch(
  qyid,
  (newVal, oldVal) => {
    getList(newVal)
  },
  { immediate: true }
)
const handleClickImg = (item: any, index: number) => {
  currentImgId.value = index
  currentImg.value = item.pmtdz
}
</script>
<style lang="less" scoped>
.activeImg {
  img {
    border: 3px solid aqua;
  }
}

.filesBox {
  transform: translateX(-523px);
  color: #fff;
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 970px !important;
  float: right !important;
  background-color: rgba(0, 0, 0, 0.5);

  .files-top {
    height: 546px;
    border: 1px solid #ccc;
    margin-top: calc(100% - 875px);

    img {
      width: 100%;
      height: 100%;
    }
  }

  .files-center {
    // height: 34%;
    border: 1px solid #ccc;
    margin: 10px 0;
  }

  .files-bottom {
    border: 1px solid #ccc;

    .processBox {
      width: 100%;
      height: 200px;
      overflow-x: auto;
      padding: 10px;
      display: flex;
      justify-content: flex-start;
      text-align: center;
    }

    .processList {
      width: 165px;
      flex-shrink: 0;
      font-size: 20px;
      font-weight: bolder;
      margin: 10px 0 0 10px;

      img {
        width: 165px;
        height: 99px;
      }
    }
  }

  .titleBox {
    padding: 5px;
    background: linear-gradient(to right, rgb(158, 109, 18), rgba(225, 225, 225, 0));
    display: flex;
    align-items: center;
    justify-content: space-between;

    span {
      font-weight: bolder;
      font-size: 18px;
    }
  }
}
</style>
